using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using SC = ShoppingCart.Business.Entity;

namespace ShoppingCart.WebSite.Code
{
    public class BaseMasterPage : MasterPage
    {
        private static string _relativeWebRoot;

        protected static string RelativeWebRoot
        {
            get { return _relativeWebRoot ?? (_relativeWebRoot = VirtualPathUtility.ToAbsolute("~/")); }
        }

        protected int IdCliente
        {
            get { return Session["IdCliente"] == null ? 0 : Convert.ToInt32(Session["IdCliente"]); }
            set { Session["IdCliente"] = value; }
        }

        protected int IdDepartamento
        {
            get { return Session["IdDepartamento"] == null ? 0 : Convert.ToInt32(Session["IdDepartamento"]); }
            set { Session["IdDepartamento"] = value; }
        }

        protected List<SC.Producto> Carrito
        {
            get { return Session["Carrito"] == null ? new List<SC.Producto>() : (List<SC.Producto>)Session["Carrito"]; }
        }

        public event EventHandler UpdateCarrito;

        protected void InvokeUpdateCarrito(EventArgs e)
        {
            if (UpdateCarrito != null) UpdateCarrito(this, e);
        }
    }
}
